<?php
	session_start();
	header("content-type:image/png");
	$img =imagecreate(100,30);
	$color=imagecolorallocate($img,rand(0,255),rand(0,255),rand(0,255));
	imagefill($img,0,0,$color);
	$string="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
	
	//$resource = fopen("checkcodefile.txt", "w");
	$ck = "";
	for($i=0;$i<4;$i++){
		$char = $string{rand(0,61)};
		$ck.=$char;
		//fputs($resource, $char);
		
		$char_color = imagecolorallocate($img,rand(0,255),rand(0,255),rand(0,255));
		imagechar($img,5,($i+1)*15,rand(0,18),$char,$char_color);
	}
	$_SESSION['ck'] = $ck;
	//fclose($resource);
	imagepng($img);
	
?>